﻿using Client.Common.Common.Event;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Client.Common.Extensions
{
    public static class DilogExtensions
    {
        /// <summary>
        /// 推送等待消息
        /// </summary>
        /// <param name="eventAggregator"></param>
        /// <param name="model"></param>
        public static void UpdateLoading(this IEventAggregator eventAggregator, UpdateModel model)
        {
            eventAggregator.GetEvent<UpdateLoadingEvent>().Publish(model);
        }

        /// <summary>
        /// 注册等待消息
        /// </summary>
        /// <param name="eventAggregator"></param>
        /// <param name="action"></param>
        public static void Register(this IEventAggregator eventAggregator, Action<UpdateModel> action)
        {
            eventAggregator.GetEvent<UpdateLoadingEvent>().Subscribe(action);
        }

        /// <summary>
        /// 注册提示消息事件
        /// </summary>
        /// <param name="eventAggregator"></param>
        /// <param name="action"></param>
        public static void RegisterMessage(this IEventAggregator eventAggregator,Action<string> action)
        {
            eventAggregator.GetEvent<MessageEvent>().Subscribe(action);
        }

        /// <summary>
        /// 发送消息事件
        /// </summary>
        /// <param name="eventAggregator"></param>
        /// <param name="model"></param>
        public static void SendMessage(this IEventAggregator eventAggregator, string model)
        {
            eventAggregator.GetEvent<MessageEvent>().Publish(model);
        }
    }
}
